package com.yanqu.road.server.cmd.drugstore;

import com.yanqu.road.pb.drugstore.DrugStoreProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.drugstore.DrugStoreModule;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_DRUG_STORE_ENTRY, desc = "进入药铺")
public class DrugStoreEntryCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        DrugStoreModule storeModule = player.getModule(DrugStoreModule.class);
        storeModule.entryView(System.currentTimeMillis());

        DrugStoreProto.DrugStoreEntryRespMsg.Builder builder = DrugStoreProto.DrugStoreEntryRespMsg.newBuilder();
        DrugStoreProto.DrugStoreTemp.Builder dataBuilder = storeModule.getUserDataBuilder();
        if(dataBuilder != null){
            builder.setUserData(dataBuilder);
            player.sendPacket(Protocol.U_DRUG_STORE_ENTRY, builder);
        }
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
